﻿using System;
using PacketRush.Core;
using System.Text;

namespace PacketRush.Core.DocExamples
{
    public class PacketReaderExamples
    {

        public void Example01(Packet packet)
        {
            #region Example01

            //
            // The code assumes we have either a reference to a instance of PacketRush.Core.Packet.
            //
            PacketReader reader = new PacketReader(packet);

            bool booleanValue;
            int intValue;
            string stringValue;

            // Read a boolean value from the packet
            if (reader.CanReadBoolean()) booleanValue = reader.ReadBoolean();

            // Read a byte value from the packet
            if (reader.CanReadInt32()) intValue = reader.ReadByte();

            // Read a string value from the packet
            if (reader.CanReadString()) stringValue = reader.ReadString(Encoding.UTF8);

            #endregion
        }
    }
}